package common.common.dao.impl;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import common.common.dao.IUserDao;
import common.common.entity.User;
@Component("userDao")
@Scope("prototype")
public class UserDaoImpl  extends GenericDaoHibernate<User, Integer> implements IUserDao {

	@Resource(name="user")
	User user;
	
	public boolean isRepeatLoginName(User loginUser) {
		
		this.user=(User) this.findByExample(loginUser);
		if(user!=null){
		return true;
		}
		return false;
	}

	public User findUserByid(int userId){
		user=this.findById(userId);
		if(user!=null){
		return user;
		}
		return null;
	}
	public User findUserByType(User loginUser){
		this.user=(User) this.findByExample(loginUser);
		if(user!=null){
			return user;
		}
		return null;
	}
	
	public List<User> findAllUser(){
	List<User>	users=new ArrayList<User>();
	     users=this.findAll();
		if(users.size()>0){
			return users;
		}
		return null;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}


}

